local addonName, addon = ...
-- #####################################################################################################################
-- 先后顺序:==>ADDON_LOADED==>PLAYER_ENTERING_WORLD
-- ADDON_LOADED:某插件的SavedVariables变量被加载和执行,之后该插件的ADDON_LOADED事件(event)被触发
-- PLAYER_ENTERING_WORLD
-- #####################################################################################################################
local frameName = "事件";
local subFrame = CreateFrame("Frame", frameName, nil, InterfaceOptionsFramePanelContainer, nil)
subFrame:Hide();
-- #####################################################################################################################
subFrame:RegisterEvent("ADDON_LOADED")
subFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
subFrame:SetScript("OnEvent", function(self, event, loadedAddon)
    if event == "ADDON_LOADED" and loadedAddon == addonName then
        self:UnregisterEvent("ADDON_LOADED")
        addon:InterfaceOptions_AddApiSubCategory(subFrame, subFrame:GetName())
    elseif event == "PLAYER_ENTERING_WORLD" then
        self:UnregisterEvent("PLAYER_ENTERING_WORLD")
    end
end)
-- #####################################################################################################################
subFrame:SetScript("OnShow", function(frame)
    --------------------------------------------------------------------------------------------------------------------------
    local title = subFrame:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
    title:SetPoint("TOPLEFT", 16, -16)
    title:SetText("事件")
    --------------------------------------------------------------------------------------------------------------------------
    -- https://wowprogramming.com/docs/events.html
    --------------------------------------------------------------------------------------------------------------------------
    local testButtonDoubleClick = CreateFrame("Button", frameName .. "_ReloadButton", frame, "UIPanelButtonTemplate")
    testButtonDoubleClick:SetText("测试按钮双击")
    testButtonDoubleClick:SetSize(180, 25)
    testButtonDoubleClick:SetEnabled(true)
    testButtonDoubleClick:SetPoint("TOPLEFT", title, "BOTTOMLEFT", -2, -16)
    testButtonDoubleClick:SetScript("OnClick", function(self, button, down)
        print("OnClick()-->button = ", button, ", down = ", down);
    end)
    testButtonDoubleClick:SetScript("OnDoubleClick", function(self, button)
        print("OnDoubleClick()-->button = ", button);
    end)
    --------------------------------------------------------------------------------------------------------------------------
    --------------------------------------------------------------------------------------------------------------------------
    --------------------------------------------------------------------------------------------------------------------------
end)
-- #####################################################################################################################